<template>
  <!--  检索框-->
  <div style="padding-top: 10px">
    <el-select v-model="tableData.school" placeholder="学校" style="width: 150px;padding-top: 5px">
      <el-option label="河南大学" value="河南大学" />
      <el-option label="湖南大学" value="湖南大学" />
      <el-option label="武汉大学" value="武汉大学" />
      <el-option label="清华大学" value="清华大学" />
      <el-option label="北京大学" value="北京大学" />
      <el-option label="南京大学" value="南京大学" />
      <el-option label="上海大学" value="上海大学" />
      <el-option label="云南大学" value="云南大学" />
      <el-option label="新疆大学" value="新疆大学" />
    </el-select>
    <el-button @click="searchBySchool" type="primary" plain>检索</el-button>
    &nbsp; &nbsp;
    <el-select v-model="tableData.major" placeholder="专业" style="width: 150px">
      <el-option label="数据结构" value="数据结构" />
      <el-option label="408" value="408" />
      <el-option label="计算机网络" value="计算机网络" />
      <el-option label="计算机组成原理" value="计算机组成原理" />
      <el-option label="微信小程序" value="微信小程序" />
      <el-option label="大学物理" value="大学物理" />
      <el-option label="高数" value="高数" />
      <el-option label="机械" value="机械" />
      <el-option label="自动化" value="自动化" />
    </el-select>
    <el-button @click="searchByMajor" type="primary" plain>检索</el-button>
    <br/>
    <el-input v-model="tableData.nickname" placeholder="请输入用户昵称" style="width: 250px;padding-top: 5px;padding-left: 10px"></el-input>
    <el-button @click="searchByNickname" type="primary" plain>检索</el-button>
    <el-input v-model="this.userId" placeholder="请输入用户Id" style="width: 300px;padding-top: 10px;padding-left: 10px"/>
    <el-button @click="searchByUserId" type="primary" style="padding-top: 15px" plain>检索</el-button>
    <el-select v-model="tableData.ip" placeholder="ip" style="width: 150px;;padding-left: 20px">
      <el-option label="河南省" value="河南省" />
      <el-option label="北京市" value="北京市" />
      <el-option label="河北省" value="河北省" />
      <el-option label="湖南省" value="湖南省" />
    </el-select>
    <el-button @click="searchByIp" type="primary" plain>检索</el-button>
  </div>

  <!--  检索结果表格-->
  <div style="padding-top: 5px">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column fixed prop="id" label="id" width="50"/>
      <el-table-column fixed prop="userId" label="用户Id" width="120"/>
      <el-table-column prop="email" label="用户邮箱" width="150" />
      <el-table-column prop="mobilePhoneNumber" label="手机号" width="100" />
      <el-table-column prop="nickname" label="昵称" width="100" />
      <el-table-column prop="ip" label="联系地址" width="200" />
      <el-table-column prop="school" label="学校" width="200" />
      <el-table-column prop="major" label="专业" width="200" />
      <!--      <el-table-column prop="coverImage" label="封面图片" width="250" />-->
      <el-table-column fixed="right" label="Operations" width="120">
        <template #default="data">
          <el-button size="small" @click="lookButton(data.row.id)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>

  <div class="demo-pagination-block">
    <div class="demonstration"></div>
    <h4>总页数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </h4>
    <el-pagination
        v-model:current-page=current
        :page-size=size
        :small="small"
        :disabled="disabled"
        :background="background"
        layout="total, prev, pager, next"
        :total=total
        @size-change="getSizeChange"
        @current-change="getCurrentPage"
    />
  </div>
</template>

<script>
import request from "@/utils/request";
import router from "@/router";
import displayArticleView from "@/views/body/displayArticleView";

export default {
  name: "AdminArticleTable",
  components: {
    displayArticleView
  },

  created() {
    this.load()
  },

  methods: {
    load() {
      request.get("/user/getAllUser/"+this.current).then(res => {
        console.log(res.data)
        if (res.data == 500) {
          alert("返回错误,返回文章检索页面!")
          router.push("/ArticleSearchView")
        } else {
          if (res.data.records!=null){
            this.tableData=res.data.records
            this.size=res.data.size
            this.pages=res.data.pages
          }
          else {
            this.tableData=res.data
          }
        }
      })
    },

    getCurrentPage(current){
      request.get("/user/getAllUser/"+current).then(res => {
        console.log(res.data)
        if (res.data.records!=null){
          this.tableData=res.data.records
          this.size=res.data.total
          this.size=res.data.size
          this.pages=res.data.pages
        }
        else {
          this.tableData=res.data
        }
      })
    },

    lookButton(articleId){
      console.log("点击："+articleId)
      router.push({
        name:"displayArticleView",
        query:{
          articleId: articleId,
        }
      })
    },

    searchByIp(){

    },
    searchByNickname(){

    },
    searchBySchool(){

    },
    searchByMajor(){

    },
    searchByUserId(){

    },

  },


  data(){
    return{
      tableData:[
        {
          id:1,
          authorId:'',
          title:'',
          summary:'',
          coverImage:'',
          weight:'',
          tagName:'',
          createDate:'',
          viewCounts:0,
        }
      ],

      userId: '',
      total: 9,
      size: 9,
      current: 1,
      pages: 10,
    }
  }

}
</script>

<style >

</style>